import hashlib
import re


def gen_md5_digest(content):
    """将字符串处理成MD5摘要"""
    return hashlib.md5(content.encode()).hexdigest()


# 正则表达式匹配用户名
USERNAME_PATTERN = re.compile(r'[0-9a-zA-Z_]{6,20}')
# 匹配手机号
PHONENO_PATTERN = re.compile(r'1[3-9]\d{9}')


def check_username(username):
    """检查用户名"""
    return USERNAME_PATTERN.fullmatch(username) is not None


def check_password(password):
    """检查密码"""
    return len(password) >= 6


def check_phoneno(tel):
    """检查手机号"""
    return PHONENO_PATTERN.fullmatch(tel) is not None
